package com.example.web.demos.controller;

import com.example.web.demos.domain.dto.Student;
import com.example.web.demos.domain.dto.Teacher;
import org.springframework.web.bind.annotation.*;

/**
 * @author: scout.du
 * @date: 2024/06/19 17:57
 **/
@RestController
@RequestMapping("/test")
public class TestController {



    /*
    * 对象参数
    * 支持
    * 1.查询参数 ?name=tom
    * 2.form data
    * 3.x-www-form-urlencoded
    * 很抽象，不总结了，自己看吧
    * */
    @PostMapping("/hello")
    public String hello(Student student, String name, Teacher teacher){

        System.out.println("-----");
        System.out.println(student);
        System.out.println(name);
        System.out.println(teacher);
        System.out.println("-----");

        return "hello";
    }

    /*
     * String参数
     * 支持
     * 1.查询参数 ?name=tom
     * 2.form data
     * 3.x-www-form-urlencoded
     *
     * */
    @PostMapping("/hello1")
    public String hello1(String name,String address){

        System.out.println("-----");
        System.out.println(name);
        System.out.println("-----");

        return "hello1";
    }

    /*
     * String参数
     * @GetMapping只支持1  @PostMapping支持 1 2 3
     * 1.查询参数 ?name=tom
     * 2.form data
     * 3.x-www-form-urlencoded
     *
     * */
    @PostMapping("/hello2")
    public String hello2(@RequestParam(name = "address") String test){

        System.out.println("-----");
        System.out.println(test);
        System.out.println("-----");

        return "hello2";
    }


    /*
    * @RequestBody只负责接收application/json
    * */
    /*
    *mvc注解大全
    *@Controller
    *@RestController
    *@RequestMapping
    *@GettingMapping
    *@PostMapping
    *@RequestParam
    *@RequestBody
    *@ResponseBody
    */



}
